package com.example.controller.contractManage;

import com.example.entity.Contract;
import com.example.entity.ContractVO;
import com.example.service.contractManage.ContractCheckService;
import com.example.util.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ----MaxCV工程师---
 *
 * @author wangbiao
 * @date2024/12/6
 * @desc
 */
@RestController
@RequestMapping("/contract/check")
public class ContractCheckController {

    @Autowired
    private ContractCheckService contractCheckService;

    /**
     * 查询check_state的值为待审核,未通过,已通过的值
     */
    @PostMapping("/checkList")
    public R checkList(@RequestBody ContractVO contractVO){

        PageHelper.startPage(contractVO.getPageNum(),contractVO.getPageSize());
        List<ContractVO> list = contractCheckService.checkList(contractVO);
        PageInfo<ContractVO> info = new PageInfo<>(list);
        return R.ok(info);
    }

    /**
     * 审核通过
     */
    @GetMapping("/ratify")
    public R ratify(int contractId){
        int i = contractCheckService.ratify(contractId);

        if (i > 0){
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 审核驳回
     */
    @GetMapping("/reject")
    public R reject(int contractId){
        int i = contractCheckService.reject(contractId);
        if (i > 0){
            return R.ok();
        }
        return R.fail();
    }


}
